from ..man import app
from dingxiang.utils.ronglianyunapi import send_message
from celery import shared_task
from tools.myredis import r
from tools.baiduapi import bdapi
import json

@app.task(name='send_sms')
def send_sms(tid, mobile, datas):
    print('-------指定celery任务----------')

    res = send_message(tid, mobile, datas)

    return res
# @app.task(name='idcard')
@shared_task
def idcard():
    baidu_list = r.list_lrange("baidu_url_list", 0, 10)
    for i in baidu_list:
        url = i.decode()
        mes = bdapi.idcard(url)
        r.set_str(url, json.dumps(mes, ensure_ascii=False))
        r.list_del("baidu_url_list", url)